package Stack;
import java.util.Arrays;

public class MyStack {
    public int[] elem;
    public int size;

    public MyStack() {
        this.elem = new int[10];
    }

    public boolean isFull(){
        return size == elem.length;
    }

    public boolean isEmpty() {
        return size == 0;
    }

    public void push(int val){
        if(isFull()){
            elem = Arrays.copyOf(elem,2*elem.length);
        }
        elem[size] = val;
        size++;
    }

    public int poll() {
        if(isEmpty()) return -1;
        size--;
        return elem[size];
    }

    public int peek(){
        return elem[size-1];
    }
}
